package com.lanxin.oa.zc.controller;

import com.lanxin.bean.*;
import com.lanxin.oa.zc.service.ZcYiDongService;
import com.lanxin.util.TimeConverter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@Controller
@RequestMapping("zcyd")
public class ZcYiDongController extends TimeConverter {
    @Autowired
    ZcYiDongService zcyd;
    @RequestMapping("select")
    public ModelAndView selectzcyd(Integer empid){
        empid=1;
        List<ZcAssetmoveapply> list=zcyd.selectzcyd(empid);
        List<ZzEmployee> emplist=zcyd.selectEmpByempName();
        List<LcFlow>lclist=zcyd.selectflow();
        List<JcBasicdatavalue>jclist=zcyd.selectJcbaseByDd();
        List<JcBasicdatavalue>jcyylist=zcyd.selectJcbaseByYdYy();
        List<ZcAsset>zclist=zcyd.selectZcaset();
        List<ZzDepartment> deptlist=zcyd.selectDeptById();
        ModelAndView mv=new ModelAndView();
        mv.addObject("list",list);
        mv.addObject("emplist",emplist);
        mv.addObject("lclist",lclist);
        mv.addObject("jclist",jclist);
        mv.addObject("deptlist",deptlist);
        mv.addObject("jcyylist",jcyylist);
        mv.addObject("zclist",zclist);
        mv.setViewName("../view/zc/zcydlist.jsp");
        return mv;
    }

    @RequestMapping("selecttj")
    public ModelAndView selectzcyd(String startDate, String endDate,Integer empid,Integer status){
        empid=1;
        List<ZcAssetmoveapply> list=zcyd.selecttiaojian(startDate,endDate,empid,status);
        List<ZzEmployee> emplist=zcyd.selectEmpByempName();
        List<LcFlow>lclist=zcyd.selectflow();
        List<JcBasicdatavalue>jclist=zcyd.selectJcbaseByDd();
        List<JcBasicdatavalue>jcyylist=zcyd.selectJcbaseByYdYy();
        List<ZcAsset>zclist=zcyd.selectZcaset();
        List<ZzDepartment> deptlist=zcyd.selectDeptById();
        ModelAndView mv=new ModelAndView();
        mv.addObject("list",list);
        mv.addObject("emplist",emplist);
        mv.addObject("lclist",lclist);
        mv.addObject("jclist",jclist);
        mv.addObject("deptlist",deptlist);
        mv.addObject("jcyylist",jcyylist);
        mv.addObject("zclist",zclist);
        mv.setViewName("../view/zc/zcydlist.jsp");
        return mv;
    }
    @RequestMapping("selectjl")
    @ResponseBody
    public List selectzc(Integer deptid){
        List empdept=zcyd.selectemp_dept(deptid);
        return empdept;
    }
    @RequestMapping("insert")
    public ModelAndView insertzcyd(ZcAssetmoveapply zcAssetmoveapply, Integer[] assetId,  Integer[] targetPlace, String[] remark){
        zcyd.insert(zcAssetmoveapply,assetId,targetPlace,remark);
          ModelAndView mv=new ModelAndView();
          mv.setViewName("redirect:select");
          return mv;
    }

    @RequestMapping("tijiao")
    public ModelAndView tijiaozcyd(Integer oid,Integer status){
        zcyd.tijiao(oid,status);
        ModelAndView mv=new ModelAndView();
        mv.setViewName("redirect:select");
        return mv;
    }

    @RequestMapping("tobanli")
    public ModelAndView tobanli(Integer oid,Integer status){
        System.out.println("++++++++++++++++");
        zcyd.tobanli(oid,status);
        ModelAndView mv=new ModelAndView();
        mv.setViewName("redirect:select");
        return mv;
    }

    @RequestMapping("toupdate")
    public ModelAndView toupdatezcyd(Integer oid){
        List<ZzEmployee> emplist=zcyd.selectEmpByempName();
        List<LcFlow>lclist=zcyd.selectflow();
        List<JcBasicdatavalue>jclist=zcyd.selectJcbaseByDd();
        List<JcBasicdatavalue>jcyylist=zcyd.selectJcbaseByYdYy();
        List<ZcAsset>zclist=zcyd.selectZcaset();
        List<ZzDepartment> deptlist=zcyd.selectDeptById();
        ZcAssetmoveapply yd= zcyd.selectbyid(oid);
        ModelAndView mv=new ModelAndView();
        mv.addObject("yd",yd);
        mv.addObject("emplist",emplist);
        mv.addObject("lclist",lclist);
        mv.addObject("jclist",jclist);
        mv.addObject("deptlist",deptlist);
        mv.addObject("jcyylist",jcyylist);
        mv.addObject("zclist",zclist);
        mv.setViewName("../view/zc/zcydupdate.jsp");
        return mv;
    }
    @RequestMapping("update")
    public ModelAndView updatezcyd(Integer[] assetId, Integer[] targetPlace, String[] remark,ZcAssetmoveapply yd,Integer[] ydoid){
        zcyd.update(assetId,targetPlace,remark,yd,ydoid);
        ModelAndView mv=new ModelAndView();
        mv.setViewName("redirect:select");
        return mv;
    }
    @RequestMapping("delete")
    @ResponseBody
    public boolean deletezcyd(ZcAssetmoveapply assetmoveapply){

        return  zcyd.delete(assetmoveapply);
    }

}
